<!DOCTYPE html>
<html>

<head>
	<meta charset="UTF-8">
	<title>YIKE MANAGER</title>
	<script src="dists/jquery-easyui/jquery.min.js" type="text/javascript" charset="utf-8"></script>
	<script src="dists/jquery-easyui/jquery.easyui.min.js" type="text/javascript" charset="utf-8"></script>
	<script src="dists/jquery-easyui/locale/easyui-lang-zh_CN.js" type="text/javascript" charset="utf-8"></script>
	<script src="dists/jquery-easyui/datagrid-dnd.js" type="text/javascript" charset="utf-8"></script>
	<script type="text/javascript" src="dists/daterangepicker/moment.min.js"></script>
	<script type="text/javascript" src="dists/daterangepicker/daterangepicker.js"></script>
	<script src="dists/super/js/super.js"></script>

	<link rel="stylesheet" href="dists/super/css/font-awesome.min.css">
	<link rel="stylesheet" href="dists/super/css/superBlack.css">
	<link rel="stylesheet" href="dists/super/css/common.css">
	<link rel="stylesheet" href="dists/daterangepicker/daterangepicker.css">
</head>

<body id="main" class="easyui-layout">
	<div data-options="region:'north',border:false" class="super-north">
		<!--顶部-->
		<div class="super-navigation">
			<!--系统名称-->
			<div class="super-navigation-title">YIKEME</div>
			<!--自定义导航-->
			<div class="super-navigation-main">
				<div class="super-setting-left">
					<ul>
						<li class="user">管理员</li>
					</ul>
				</div>
				<div class="super-setting-right">
					<ul>
						<li onclick="app_cache.methods.signOut()"><i class="fa fa-sign-out"></i>注销</li>
					</ul>
				</div>
			</div>
		</div>
	</div>
	<div data-options="region:'west',title:'MAIN NAVIGATION',border:false" class="super-west">
		<!--左侧导航-->
		<div class="easyui-accordion menu_accordion" data-options="border:false,fit:true,selected:true"></div>
	</div>
	<div data-options="region:'center'" style="padding-top: 2px;">
		<!--主要内容-->
		<div id="tt" class="easyui-tabs" data-options="border:false,fit:true"></div>
	</div>
	<div data-options="region:'south'" class="super-south">
		<!--页脚-->
		<div class="super-footer-info">
			<span><i class="fa fa-info-circle"></i> 作者：YIKE Team</span>
			<span><i class="fa fa-copyright"></i> CopyRight 2019 版权所有 <i class="fa fa-caret-right"></i></span>
		</div>
	</div>
</body>

<script>
	var app_cache = {
		datas: {},
		methods: {
			initPage: function () {
				$('.user').html('欢迎您，' + localStorage.getItem('userName'));
			},
			initMenu: function () {
				// 格式化数据
				var menu = JSON.parse(localStorage.getItem('authorities'))
				var menu_tree = [];
				// 一级
				menu.map(function (e) {
					e.parentId == 0 && menu_tree.push(e)
				})
				menu_tree.sort(function (a, b) {
					return a.orderNum - b.orderNum
				})
				// 按钮
				menu.map(function (e, i) {
					var child_menu = menu.filter((m) => {
						return m.parentId == e.id
					})
					child_menu.sort(function (a, b) {
						return a.orderNum - b.orderNum
					})
					e.children = child_menu
				})
				// 二级
				menu_tree.map(function (e, i) {
					var child_menu = menu.filter((m) => {
						return m.parentId == e.id
					})
					child_menu.sort(function (a, b) {
						return a.orderNum - b.orderNum
					})
					e.children = child_menu
				})
				// DOM
				var menu_html = ''
				menu_tree.map(function (e, i) {
					var child_menu_html = ''
					e.children.map(function (_e) {
						child_menu_html += `<li data-url='${_e.url}'>${_e.name}</li>`
					})
					$('.menu_accordion').accordion('add', {
						title: e.name,
						iconCls: e.icon || 'fa fa-support',
						selected: i == 0,
						content: '<ul>' + child_menu_html + '</ul>',
					});
				})
				// EVENT
				app_cache.events.initMenu()
			},
			signOut: function () {
				tools.clearLocalStorage()
				window.location.href = './login.html';
			},
		},
		events: {
			initMenu: function () {
				// 左侧导航分类选中样式
				$(".panel-body .accordion-body>ul").on('click', 'li', function () {
					$(this).siblings().removeClass('super-accordion-selected');
					$(this).addClass('super-accordion-selected');

					//新增一个选项卡
					var tabUrl = $(this).data('url');
					var tabTitle = $(this).text();
					//tab是否存在
					if ($("#tt").tabs('exists', tabTitle)) {
						$("#tt").tabs('select', tabTitle);
					} else {
						$('#tt').tabs('add', {
							title: tabTitle,
							href: tabUrl,
							closable: false
						});
					}
				});
//				$('#tt').tabs('add', {
//					title: '用户反馈',
//					href: 'shop/shop/feedback_list.html',
//					closable: false
//				});
				$(".panel-body .accordion-body>ul > li").eq(5).trigger('click');
			}
		},
		init: function () {
			app_cache.methods.initPage()
			app_cache.methods.initMenu()
		}
	};
	$(function () {
		// window.onbeforeunload = function () {
		// 	var warning = "确认退出?";
		// 	return warning;
		// }
		app_cache.init();
	});
</script>

</html>